package cn.tianshi.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lin2.zhang
 */
@Slf4j
@RestController
@RequestMapping("/cache")
public class CacheController {
    private int i = 0;

    @GetMapping
    @Cacheable(value = "one", key = "#key")
    public String getCacheString(String key) {
        log.info(String.valueOf(++i));
        return "hello";
    }
}
